<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script src="jquery-3.5.1.min.js"></script>
</head>
<body>
<button>显示数据</button>
<script>
    const arr=localStorage.getItem('shop')
    console.log(arr)
  $.ajax({
    type:"get",
    url:"arr",
    data:{
      uname:"zhangshan"
    },
      dataType:"json",
    success:function (data){
        console.log(data);
        let ul=$("<ul></ul>")
        for (let i = 0; i < data.length; i++) {
            let user=data[i]
            let li="<li>"+user.username+"</li>"
            ul.append(li)
        }
        const btn=document.querySelector('button')
        let a=true
        btn.addEventListener('click',function (){
            if (a){
                $('body').append(ul)
                a=false
            }
            else {
                $('body').children().get($('body').children().length-1).remove()
                a=true
            }
        })
    }

  })
</script>
</body>
</html>